import java.util.Scanner;

public class Main1292 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next().substring(2);//eg:oxFFF
        char[] c = str.toCharArray();
        int len = c.length;
        double sum = 0;
        for (int i = 0; i < len; i++) {
            if (c[i] < 'A') {
                sum = sum + (c[i] - 48) * Math.pow(16, i);//ascall  0是48
            } else {
                sum = sum + (c[i] - 55) * Math.pow(16, i);//ascall    A是65
            }
        }

        System.out.println(sum);
    }
}